{% extends 'admin-v2/layout.html.twig' %}

{% do script(['app/js/admin-v2/operating/report-content-audit/index.js']) %}

{% set menu = 'admin_v2_report_content_audit' %}
{% block main %}
  <form id="report-search-form" class="form-inline well well-sm" action="" method="get" novalidate>
    <div class="form-group">
      <select class="form-control" name="module">
        {{ select_options(dict('reportModule'), app.request.get('module')|default(''), {'':'admin_v2.operation.report_content_audit.target_type_placeholder'|trans}) }}
      </select>
    </div>
    <div class="form-group">
      <select class="form-control" name="status">
        {{ select_options(dict('reportAuditStatus'), app.request.get('status')|default('none_checked'),{'all':'admin_v2.operation.report_content_audit.status_placeholder'|trans}) }}
      </select>

    </div>
    <div class="form-group">
      <select class="form-control" name="reportTag">
        {{ select_options(dict('reportTags'), app.request.get('reportTag')|default(''),{'':'admin_v2.operation.report_content_audit.report_tag_placeholder'|trans}) }}
      </select>
    </div>
    <div class="form-group">
      <input class="form-control" type="text"
             placeholder="{{ 'admin_v2.operation.report_content_audit.author_placeholder'|trans }}" name="author"
             value="{{ app.request.get('author') }}">
    </div>
    <button class="btn btn-primary">{{ 'form.btn.search'|trans }}</button>
  </form>

  <div id="audit-table-container">
    <table class="table table-striped table-hover audit-table" id="audit-table">
      <thead>
      <tr>
        <th width="4%"><input type="checkbox" data-role="batch-select"></th>
        <th width="40%">{{ 'admin_v2.operation.report_content_audit.table.content'|trans }}</th>
        <th>{{ 'admin_v2.operation.report_content_audit.table.type'|trans }}</th>
        <th>{{ 'admin_v2.operation.report_content_audit.table.count'|trans }}</th>
        <th width="10%">{{ 'admin_v2.operation.report_content_audit.table.tag'|trans }}</th>
        <th>{{ 'admin_v2.operation.report_content_audit.table.author'|trans }}</th>
        <th>{{ 'admin_v2.operation.report_content_audit.table.status'|trans }}</th>
        <th>{{ 'admin_v2.operation.report_content_audit.table.auditor'|trans }}</th>
        <th>{{ 'admin_v2.operation.report_content_audit.table.operate'|trans }}</th>
      </tr>
      </thead>
      <tbody>
      {% set reportTargetType = dict('reportTargetType')|default(null) %}
      {% set reportModules = dict('reportModule') %}
      {% set reportAuditStatus = dict('reportAuditStatus')|default(null) %}
      {% set reportTags = dict('reportTags')|default(null) %}

      {% for reportAudit in reportAudits|default([]) %}
        <tr id="audit-table-tr-{{ reportAudit.id }}" data-role="item">
          <td><input type="checkbox" value="{{ reportAudit.id }}" data-role="batch-item"></td>
          <td>
            <div class="short-long-text">
              <div class="short-text">
                {{ reportAudit.content|default('')|raw|plain_text(200) }}
                <span class="text-muted trigger">({{ 'admin.course_thread.expand_td'|trans }})</span>
              </div>
              <div class="long-text">{{ reportAudit.content|default('')|raw }}
                <span class="text-muted trigger">({{ 'admin.course_thread.collapse_td'|trans }})</span>
              </div>
            </div>
          </td>
          <td>{{ reportModules[reportAudit.module]|default('') }}</td>
          <td>{{ reportAudit.reportCount|default(0) }}</td>
          <td>
            {% for tag in reportAudit.reportTags %}
              <div class="pts text-sm">{{ reportTags[tag] }}</div>
            {% endfor %}
          </td>
          <td>
            {% set author = users[reportAudit.author]|default([]) %}
            {{ admin_macro.user_link(author) }}<br>
            <span class="text-muted">{{ reportAudit.contentUpdatedTime|date('Y-n-d H:i') }}</span>
          </td>
          <td class="text-{{ reportAudit.status }}" align="center">
            {{ reportAuditStatus[reportAudit.status]|default(reportAuditStatus.none_checked) }}
            {% if 'illegal' == reportAudit.status and reportAudit.auditor == '-1' %}
              <div class="text-illegal">{{ 'admin_v2.operation.audit_center.table.status.sys_illegal'|trans }}</div>
            {% endif %}
          </td>
          <td>
            {% if reportAudit.auditor == '-1' %}
              {{ 'admin_v2.operation.report_content_audit.table.auditor_default'|trans }}
            {% elseif reportAudit.auditor|default() %}
              {% set auditor = users[reportAudit.auditor]|default([]) %}
              {{ admin_macro.user_link(auditor) }}<br>
            {% else %}
              --
            {% endif %}
          </td>
          <td>
            <a class="btn btn-sm btn-default operating-btn" data-toggle="modal" data-target="#modal"
               data-url="{{ path('admin_v2_report_record', {auditId: reportAudit.id}) }}">
              {{ 'admin_v2.operation.report_content_audit.table.operate_item'|trans }}</a>
            <a
              class="btn btn-sm btn-info operating-btn js-table-item-operate {% if reportAudit.status == 'pass' %}hide{% endif %}"
              data-url="{{ path('admin_v2_report_content_audit_update_status', {id: reportAudit.id, status: 'pass'}) }}">
              {{ 'admin_v2.operation.report_content_audit.table.operate_pass'|trans }}
            </a>
            <a
              class="btn btn-sm btn-danger operating-btn js-table-item-operate {% if reportAudit.status == 'illegal' %}hide{% endif %}"
              data-url="{{ path('admin_v2_report_content_audit_update_status', {id: reportAudit.id, status: 'illegal'}) }}">
              {{ 'admin_v2.operation.report_content_audit.table.operate_illegal'|trans }}
            </a>
          </td>
        </tr>
      {% else %}
        <tr>
          <td colspan="20">
            <div class="empty">{{ 'site.datagrid.empty'|trans }}</div>
          </td>
        </tr>
      {% endfor %}
      </tbody>
    </table>

    <div class="js-batch-operate">
      <label class="checkbox-inline" data-role="batch-manage">
        <input type="checkbox" data-role="batch-select">{{ 'site.datagrid.radios.all'|trans }}
      </label>
      <a class="btn btn-sm btn-info js-batch-operate-btn" data-status="pass"
         data-url="{{ path('admin_v2_report_content_audit_batch_update', {status:'pass'}) }}">
        {{ 'admin_v2.operation.audit_center.table.batch_pass'|trans }}
      </a>
      <a class="btn btn-sm btn-danger js-batch-operate-btn" data-status="illegal"
         data-url="{{ path('admin_v2_report_content_audit_batch_update', {status:'illegal'}) }}">
        {{ 'admin_v2.operation.audit_center.table.batch_illegal'|trans }}
      </a>
    </div>
  </div>

  {{ admin_macro.paginator(paginator) }}
{% endblock %}
